﻿using System;
using System.Text;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;

public static class ErrorHandler 
{
public static void HandleException(Exception ex)
{
    if (ex == null) return;

    Exception exceptionLayer = null;
    if (ex is HttpUnhandledException)
    {
        if (ex.InnerException != null) exceptionLayer = ex.InnerException;
    }
    else
    {
        exceptionLayer = ex;
    }
    StringBuilder sb = new StringBuilder();
    while (exceptionLayer != null)
    {
        sb.AppendLine(ex.ToString());
        sb.AppendLine("------------------------");
        exceptionLayer = exceptionLayer.InnerException;
    }
    //Log(sb.ToString());
    }
}
